package com.example.grape_effect.zzztest

import android.content.Context
import android.graphics.Color
import android.util.Log
import android.view.Gravity
import android.view.View
import android.view.ViewGroup
import android.widget.BaseAdapter
import android.widget.TextView
import com.example.grape_effect.gl.common.GLProgram
 class LYAdapter(var context: Context): BaseAdapter() {
     var glProgramList = ArrayList<GLProgram>()
//     init {
//         glProgramList.add(TranslateTransition(TranslateTransition.leftToRight))
//         glProgramList.add(TranslateTransition(TranslateTransition.rightToLeft))
//         glProgramList.add(TranslateTransition(TranslateTransition.topToBottom))
//         glProgramList.add(TranslateTransition(TranslateTransition.bottomToTop))
//     }

     var choiceProgram: GLProgram? = null
     fun getCurGLProgram(): GLProgram? {
//         val trans = choiceProgram as TranslateTransition
//         LogUtil.e("transName = " + trans.name)
         choiceProgram?.let {
             Log.e("LYAdapter", "transName = " + it.name)
         }
         return choiceProgram
     }

     override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View {
         val textView = TextView(context)
         textView.height = 125
         textView.setBackgroundColor(0xFF555555.toInt())
         textView.gravity = Gravity.CENTER
         textView.text = glProgramList[position].name
         Log.e("LYAdapter", "text = " + textView.text + " positin = " + position)
         textView.setTextColor(Color.BLACK)
         textView.setTextColor(-0x1000000)
         textView.setOnClickListener(object: View.OnClickListener{
             override fun onClick(v: View?) {
                 choiceProgram = glProgramList[position]
             }
         })
         return textView
     }

     override fun getItem(position: Int): Any {
         return glProgramList[position]
     }

     override fun getItemId(position: Int): Long {
         return position.toLong()
     }

     override fun getCount(): Int {
         return glProgramList.size
     }
 }